package ch.sv7.tool.dbmanager.db.difference;

import ch.sv7.tool.dbmanager.db.IndexSchema;
import ch.sv7.tool.dbmanager.db.TableSchema;

/**
 *
 * @author svt
 *
 */
public abstract class AbstractIndexDifference extends AbstractTableDifference {

	private IndexSchema expectedIndex;
	private IndexSchema actualIndex;


	/**
	 * @param tableName
	 */
	public AbstractIndexDifference(TableSchema expectedTableSchema, TableSchema actualTableSchema, IndexSchema expectedIndex, IndexSchema actualIndex) {
		super(expectedTableSchema, actualTableSchema);
		this.expectedIndex = expectedIndex;
		this.actualIndex = actualIndex;
	}


	/**
	 * @return the index
	 */
	public IndexSchema getActualIndex() {
		return actualIndex;
	}

	/**
	 * @return the index
	 */
	public IndexSchema getExpectedIndex() {
		return expectedIndex;
	}

	public String getMessage(){
		return super.getMessage() 
		+ " index " + (actualIndex.getName() == null ? "unnamed" : actualIndex.getName())
		+ (getActualIndex().isUnique() ? "[unique]" : "[non-unique]") 
			+ " on column(s): " + getActualIndex().getColumns();		
	}
	
}
